<template>
  <div class="taskPackageMy">
    <c-title :hide="false" text="任务包"></c-title>
    <div class="headBox">
      <div class="userBox" v-if="dataInfo.member_data">
        <div class="userBoxImg">
          <img :src="dataInfo.member_data.avatar" alt="" />
        </div>
        <div class="userBox_right">
          <div class="name">
            <span class="van-ellipsis nickspan">{{ dataInfo.member_data.nickname }}</span>
            <div class="code" v-if="dataInfo.member_data.line_code">
              <span class="codetext">流量码: {{ dataInfo.member_data.line_code }}</span>
              <div class="copy" v-clipboard:copy="dataInfo.member_data.line_code" v-clipboard:success="onCopy">复制</div>
            </div>
          </div>
          <div class="gradeBox" v-if="dataInfo.member_data.level_name">
            <div class="grade">{{ dataInfo.member_data.level_name }}</div>
          </div>
        </div>
      </div>
      <!-- <router-link :to="fun.getUrl('taskPackageRecord', { type: 7 })" v-if="dataInfo.sub_team_show"> -->
      <div class="nextGrade" @click="toTeam">下级团队人数：{{ dataInfo.sub_team_count }} <van-icon name="arrow" v-if="dataInfo.sub_team_show" /></div>
    </div>
    <div class="detailBox">
      <div class="detailLis dbottom" v-if="dataInfo.active_show">
        <div class="num">{{ dataInfo.active_value }}</div>
        <div class="txt">总贡献值</div>
      </div>
      <div class="detailLis dbottom" v-if="dataInfo.contribution_show">
        <div class="num">{{ dataInfo.contribution_value }}</div>
        <div class="txt">贡献值</div>
      </div>
      <div class="detailLis">
        <div class="num">{{ dataInfo.proceduresFeeTotal }}</div>
        <div class="txt">手续费分红</div>
      </div>
      <div class="detailLis">
        <div class="num">{{ dataInfo.platformFlowTotal }}</div>
        <div class="txt">平台流水分红</div>
      </div>
    </div>
    <div class="otherBox">
      <div class="otherLis">
        <router-link :to="fun.getUrl('taskPackageIndex', {})">
          <img src="@/assets/images/taskPackage/task@2x.png" alt="" />
          <div class="name">任务商城</div>
        </router-link>
      </div>
      <div class="otherLis" v-if="dataInfo.active_show">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 2 })">
          <img src="@/assets/images/taskPackage/liveness@2x.png" alt="" />
          <div class="name">总贡献值记录</div>
        </router-link>
      </div>
      <div class="otherLis" v-if="dataInfo.contribution_show">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 3 })">
          <img src="@/assets/images/taskPackage/contribution@2x.png" alt="" />
          <div class="name">贡献值记录</div>
        </router-link>
      </div>
      <div class="otherLis">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 4 })">
          <img src="@/assets/images/taskPackage/resurgence@2x.png" alt="" />
          <div class="name">复活记录</div>
        </router-link>
      </div>
      <div class="otherLis">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 5 })">
          <img src="@/assets/images/taskPackage/procedure@2x.png" alt="" />
          <div class="name">手续费分红</div>
        </router-link>
      </div>
      <div class="otherLis">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 6 })">
          <img src="@/assets/images/taskPackage/water@2x.png" alt="" />
          <div class="name">平台流水分红</div>
        </router-link>
      </div>
      <div class="otherLis" @click="tolove">
        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Flove%402x.png" alt="" />
        <div class="name">{{ $store.state.temp.designer.love_name }}产值记录</div>
      </div>
      <div class="otherLis">
        <router-link :to="fun.getUrl('taskPackageRecord', { type: 8 })">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fexchange%402x.png" alt="" />
          <div class="name">兑换记录</div>
        </router-link>
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      dataInfo: []
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    tolove() {
      this.$router.push(this.fun.getUrl("love_list", {}));
    },
    toTeam() {
      if (this.dataInfo.sub_team_show) {
        this.$router.push(this.fun.getUrl("taskPackageRecord", { type: 7 }));
      }
    },
    // 复制文案
    onCopy() {
      Toast({
        message: "复制成功",
        position: "bottom",
        duration: 5000
      });
    },
    getData() {
      $http.post("plugin.task-package.frontend.index.member-data", {}, " ").then(response => {
        //区别商品是否可售
        if (response.result == 1) {
          this.dataInfo = response.data;
        } else {
          this.$dialog.alert({
            message: response.msg
          });
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.otherBox {
  margin: 0.63rem;
  display: flex;
  flex-wrap: wrap;
  background: #fff;
  padding: 1.25rem 0 0.56rem 0;
  // .otherLis_top {
  //   margin-top: 1.44rem;
  // }
  .otherLis:nth-child(5) {
    margin-top: 1.44rem;
  }

  .otherLis:nth-child(6) {
    margin-top: 1.44rem;
  }

  .otherLis:nth-child(7) {
    margin-top: 1.44rem;
  }

  .otherLis:nth-child(8) {
    margin-top: 1.44rem;
  }

  .otherLis {
    width: 25%;

    img {
      width: 2.19rem;
      height: 2.19rem;
      border-radius: 100%;
    }

    .name {
      margin-top: 0.55rem;
      font-size: 0.75rem;
      color: #222;
    }
  }
}

.detailBox {
  margin: 0.63rem;
  padding: 1.03rem 0;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  border-radius: 0.31rem;

  .dbottom {
    margin-bottom: 1.63rem;
  }

  .detailLis {
    width: 50%;
    display: flex;
    flex-direction: column;

    .num {
      font-size: 1rem;
      margin-bottom: 0.66rem;
    }

    .txt {
      font-size: 0.69rem;
    }
  }
}

.headBox {
  padding: 1.28rem 0.97rem 0.69rem 0.97rem;
  background: #ff8924;
  box-sizing: border-box;

  .nextGrade {
    text-align: left;
    font-size: 0.69rem;
    color: #fff;
    margin-top: 0.66rem;
    margin-left: 3.88rem;
    display: flex;
    align-items: center;

    i {
      margin-top: 2px;
    }
  }

  .userBox {
    display: flex;

    .userBox_right {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1;
      overflow: hidden;

      .name {
        text-align: left;
        font-size: 1rem;
        color: #fff;
        font-weight: bold;
        display: flex;
        align-items: center;

        .nickspan {
          flex-shrink: 0;
          max-width: 40%;
        }

        .code {
          flex: 1;
          font-weight: 400;
          font-size: 0.69rem;
          margin-left: 1rem;
          overflow: hidden;
          display: flex;

          .codetext {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .copy {
            flex-shrink: 0;
            margin-left: 0.41rem;
            padding: 0.22rem 0.56rem;
            border-radius: 0.52rem;
            font-size: 0.63rem;
            line-height: 0.63rem;
            background: #fff;
            color: #ff8924;
          }
        }
      }

      .gradeBox {
        display: flex;
        justify-content: flex-start;

        .grade {
          text-align: left;
          padding: 0.28rem 0.66rem;
          border-radius: 0.63rem;
          background: #fff;
          color: #ba750c;
          font-size: 0.69rem;
        }
      }
    }

    .userBoxImg {
      flex-shrink: 0;
      width: 3.44rem;
      height: 3.44rem;
      border-radius: 100%;
      margin-right: 0.44rem;
      background: #ba750c;

      img {
        width: 100%;
        height: 100%;
        border-radius: 100%;
      }
    }
  }
}
</style>